﻿#pragma once

struct _stLandedTitlesProperty;
struct _stCharacterData;
struct _stProvinceInfo;

struct _stLandedTitlesData
{
public:
	_stLandedTitlesData(const _stLandedTitlesProperty* p);
	
	const _stLandedTitlesProperty* m_pLandedTitlesProperty = nullptr;

	_stProvinceInfo* m_pCountyPalatine;	// 伯爵领
	
	// 拥有者
	_stCharacterData* m_pOwner = nullptr;		// 指向CCharacterData::m_mapCharacterData中的数据
	_stLandedTitlesData* m_pDeJureFather;		// 法理上级
	std::unordered_map<std::wstring, _stLandedTitlesData*> m_mapDeJureChild;		// 法理下级 用map是方便根据key查找
	// 直属上级
	// 直属下级
	// 历史拥有者

	std::wstring GetFlagPath() const { return m_wFlagPath; }
	std::wstring GetDisplayName();		// 如"Kent"
	std::wstring GetTitleslevelDisplayName() const;		// 如"count"
	bool IsAvailable() const { return nullptr != m_pLandedTitlesProperty; }
private:
	std::wstring m_wFlagPath = L"\\ResFile\\GUI\\Flags\\";		// 纹理路径

	std::wstring m_wstr_DisplayName;	// 从翻译文件中拿到的显示名称
};

class CLandedTitlesData
{
	friend class CProgramDataMgr;	// 只有CProgramDataMgr能实例化
public:
	~CLandedTitlesData() = default;
private:
	CLandedTitlesData() = default;
	CLandedTitlesData(const CLandedTitlesData&) = delete;
	CLandedTitlesData& operator =(const CLandedTitlesData&) = delete;
public:
	void LinkWithProvinceData(_stProvinceInfo* pCountyPalatine);

	void CreateDataAfterLandedTitlesPropertyRead();
private:
	std::unordered_map<std::wstring, _stLandedTitlesData> m_mapLandedTitlesData;	// m_pst_LandedTitlesProperty->m_wstr_LandedTitles 作为KEY

	void RecursiveChildNode(_stLandedTitlesData* pHead);
};